import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'

Vue.use(Vuex);

export default new Vuex.Store({
  state:{
    flow:{},
    loginInfo:null,//保存用户的登录信息
  },
  getters:{
    getFlow:state=>{
      return state.flow;
    },
    getLoginInfo:state=>{
      //如果从session中取
     state.loginInfo=JSON.parse(sessionStorage.getItem('login_user'));
     return state.loginInfo;
    }

  },
  mutations:{
    SetFlow(state,params){
        this.state.flow=params.data.data.data;
      //console.log(params.data.data.data)
    }


  },
  actions:{
    loadFlow:state=>{
      //axios取数据
      let data;
      let url='https://www.dragonjun.com/jersey/api/user/get_flow';
      axios.post(url,data,{
        headers: {
          'Content-Type': 'application/json',
        }
      }).then(function (data) {
       // console.log(data);
        state.commit('SetFlow',{data})
      }).catch(function (error) {
        console.log('错误'+error);
      })
    }
  }

})
